package JZOffer;

// 数组中重复出现的数字
public class JzOffer03 {
    public int findRepeatNumber(int[] nums) {
        int index = 0;
        while (index < nums.length) {
            if (nums[index] == index) {
                index++;
                continue;
            }
            if (nums[index] == nums[nums[index]]) {
                return nums[index];
            }
            int tmp = nums[index];
            nums[index] = nums[tmp];
            nums[tmp] = tmp;
        }
        return -1;
    }
}
